Should *'s go next to the type or the variable name? [closed]

Posted by derekerdmann on Programmers See other posts from Programmers or by derekerdmann
Published on 2010-12-20T20:53:32Z Indexed on 2011/02/16 15:33 UTC
Read the original article Hit count: 361

Filed under:
|
|
|

Possible Duplicate:
int* i; or int *i; or int * i;

When working in C or C++, how should pointers be declared? Like this:

char* derp;

or this:

char *derp;

I typically use the first method, because the variable is a character pointer, but I know that it can create confusion when declaring multiple variables at once:

char* herp, derp;

herp becomes a character pointer, while derp is just a character.

I know it often comes down to coding style, but which one is "better?" Should I sacrifice clarity to eliminate potential confusion?

© Programmers or respective owner

Related posts about c++

Related posts about c